package com.jiyinit.web.core.business.service;

import com.jiyinit.core.framework.base.util.Check;
import com.jiyinit.web.core.business.dao.TabCoreRoleResourceDao;
import com.jiyinit.web.core.business.entity.TabCoreRoleResourceEntity;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * <p></p>
 * <p>
 * <PRE>
 * <BR>	修改记录
 * <BR>-----------------------------------------------
 * <BR>	修改日期			修改人			修改内容
 * </PRE>
 *
 * @author lishaochuan
 * @version 1.0
 * @date 2017/4/21 16:15
 * @since 1.0
 */
@Service("core.roleResourceServiceImpl")
public class RoleResourceServiceImpl {

    @Resource(name = "core.tabCoreRoleResourceDao")
    private TabCoreRoleResourceDao tabCoreRoleResourceDao;


    /**
     * 修改角色权限关系表
     * 1、先删除
     * 2、再插入
     * @author lishaochuan
     * @create 2017/4/21 16:39
     * @param
     * @return
     */
    public void updateRoleResource(Integer roleId, List<TabCoreRoleResourceEntity> roleResources) {
        tabCoreRoleResourceDao.deleteByRoleId(roleId);
        if(!Check.isNullCollection(roleResources)){
            tabCoreRoleResourceDao.bathSave(roleResources);
        }
    }
}
